package com.my.designPattern_old;

import java.util.Date;

/**
 * 单例模式之一 饿汉模式
 */
public class Singleton {

    private String name = "zlx";

    private static Singleton singleton = new Singleton("zlx");

    private Singleton(String name){
        this.name = name;
    }

    public static Singleton getSingleton(){
        System.out.println("date=======" + new Date());
        return singleton;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static void setSingleton(Singleton singleton) {
        Singleton.singleton = singleton;
    }
}
